package com.codi.bus.core.service.organ;

import com.codi.bus.core.domain.OrganProfile;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * 机构资料
 *
 * @author shi.pengyan
 * @version 1.0 2017-09-01 9:16
 * @since 1.0
 */
public interface OrganProfileService {

    String TABLE_NAME = "fund_organ_profile";

    String COLUMN_BIZ_LICENCE = "business_licence";

    String PRIMARY_KEY = "profile_id";

    int NOTIFY_YES = 1;

    int NOTIFY_NO = 0;


    /**
     * 通过主键查询机构信息
     *
     * @param profileId 企业id
     * @return
     */
    OrganProfile getById(Long profileId);

    /**
     * 增加或更新机构资料
     *
     * @param record
     * @return
     */
    OrganProfile addOrUpdateByProfileId(OrganProfile record);


    /**
     * 通过用户
     *
     * @param userId
     * @return
     */
    OrganProfile qryByUserId(Long userId);


    OrganProfile qryByProfileId(Long profileId);

    OrganProfile queryByAgentId(Long agentId);


    List<OrganProfile> queryListByUserId(Long userId);


    List<OrganProfile> queryListByAgentId(Long agentId);

    /**
     * 更新profile 状态
     *
     * @param profileId
     * @param state     GlobalConstant.ORGAN_STATE_xx
     * @return
     */
    int updateState(Long profileId, int state);

    /**
     * 更新机构的风险测评过期时间
     *
     * @param userId
     * @param effectTimeStr
     * @return
     */
    String updateUserRiskLevelExpireTime(Long userId, String effectTimeStr);

    /**
     * 判断是否 营业执照号是否唯一
     *
     * @param businessLicence
     * @return
     */
    boolean checkBizLicenseExist(String businessLicence);

    /**
     * 除了自己是否唯一
     *
     * @param businessLicence
     * @param primaryKey
     * @return
     */
    boolean checkBizLicenseExist(String businessLicence, Long primaryKey);

    /**
     * 分页查询
     *
     * @param record
     * @param pageable
     * @return
     */
    Page<OrganProfile> query(OrganProfile record, Pageable pageable);


    /**
     * 审核通过之后，确认已通知用户
     *
     * @param userId
     */
    void confirmPassNotifyUser(Long userId, Long profileId);


}
